Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Markdown flavours

Nodes render to the Markdown of a flavour. The default flavour, material, is Markdown for Material for MkDocs / Zensical, using Python-Markdown / PyMdown extensions (admonitions, tabs, attribute lists, …). The github flavour produces GitHub flavoured Markdown for READMEs, issues and wikis: alerts, <details> blocks, <kbd> and plain fenced code. The mdbook flavour is the GitHub flavour for mdBook (optionally with mdbook-admonish admonitions), the myst flavour the GitHub flavour with MyST directives (admonitions, dropdowns, tab sets, {code-block}) for Sphinx.

import mknodes as mk

node = mk.MkAdmonition("Careful!", typ="warning")
node.to_markdown()  # Material (default)
node.to_markdown(flavor="github")  # > [!WARNING] ...

A whole site can be generated in a flavour with the CLI. The markdown engine writes plain Markdown files plus a SUMMARY.md nav and defaults to github:

mknodes generate --engine markdown --flavor github --generated-dir build/markdown

Each engine has a default flavour, see Site engines. The flavour can also be set with the flavor setting (see Configuration) or passed to DocBuilder. The renderer classes are documented in Core API / Rendering.

Side by side

Each node is shown as rendered on this site, followed by its Markdown in both flavours.

Admonition

Warning

Careful

Content with Markdown.

Material

!!! warning "Careful"
    Content with **Markdown**.

GitHub

> [!WARNING]
> **Careful**
>
> Content with **Markdown**.

Collapsible admonition

Click me

Hidden until clicked.

Material

??? info "Click me"
    Hidden until clicked.

GitHub

<details>
<summary>Click me</summary>

Hidden until clicked.

</details>

Tabs

Python
import mknodes as mk
Shell
pip install mknodes

Material

===! "Python"
    ``` {.py }
    import mknodes as mk
    ```

=== "Shell"
    ``` {.bash }
    pip install mknodes
    ```

GitHub

<details open>
<summary>Python</summary>

```py
import mknodes as mk
```

</details>

<details>
<summary>Shell</summary>

```bash
pip install mknodes
```

</details>

Code block with title

build.py

import mknodes as mk

nav = mk.MkNav()

Material

``` {.py  title='build.py'}
import mknodes as mk

nav = mk.MkNav()
```

GitHub

**build.py**

```py
import mknodes as mk

nav = mk.MkNav()
```

Keys

Ctrl+Alt+Del

Material

++ctrl+alt+del++

GitHub

<kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Del</kbd>

Details block

More info

Some details.

Material

/// details | More info
    type: tip

Some details.
///

GitHub

<details>
<summary>More info</summary>

Some details.

</details>

Definition list

MkNav

A section of the documentation.

MkPage

A page of the documentation.

Material

MkNav
:   A section of the documentation.
MkPage
:   A page of the documentation.

GitHub

<dl>
<dt>MkNav</dt>
<dd>

A section of the documentation.

</dd>
<dt>MkPage</dt>
<dd>

A page of the documentation.

</dd>
</dl>

Critic markup

Inserted text

Material

{++

Inserted text

++}

GitHub

<ins>

Inserted text

</ins>

Progress bar

██████░░░░ 60%

Material

[=60% "60%"]

GitHub

`██████░░░░` 60%

github Repository

Material

[:mdi-github: Repository](https://github.com/phil65/mknodes)

GitHub

[<img src="https://api.iconify.design/mdi/github.svg?height=16" alt="github"> Repository](https://github.com/phil65/mknodes)

Material badge

tag 4.1.0

Material

<span class="md-typeset mdx-badge">
  <span class="mdx-badge__icon">:mdi-tag:</span>
  <span class="mdx-badge__text">4.1.0</span>
</span>

GitHub

<img src="https://api.iconify.design/mdi/tag.svg?height=16" alt="tag"> <code>4.1.0</code>

Docstrings

mknodes.rendering.github.alert

def alert(typ: str, text: str, title: str | None = None) -> str

Return a GitHub alert block (> [!NOTE]).

Material

::: mknodes.rendering.github.alert
    options:
      heading_level: 4
      show_root_heading: True

GitHub

#### <a id="mknodes.rendering.github.alert"></a>`mknodes.rendering.github.alert`

```python
def alert(typ: str, text: str, title: str | None = None) -> str
```

Return a GitHub alert block (`> [!NOTE]`).

GitHub rules

How the github flavour renders each node. A node either has a rule (a render function registered with GithubRenderer.rule, also used for subclasses which don’t render themselves), an [output.github] template in its node file, or renders its default Markdown, the same as in the material flavour. That is fine for plain Markdown (text, tables, lists); output that needs Markdown extensions (last column) may not display on GitHub. Containers rendering their default Markdown still render their children in the GitHub flavour, and hand-written Material admonitions / tabs in page text get converted.

NodeGitHub outputDetailsExtensions of the Material output
MkAdmonitionRuleadmonition, pymdownx.details, pymdownx.superfences
MkAnnotationsDefaultpymdownx.superfences
MkBadgeRuleA shields.io badge image (GitHub drops inline SVG).
MkBinaryImageTemplate of MkImage[output.github] in the node file
MkBlockRuleUnknown PyMdown blocks: keep the content, drop the block.
MkBlockQuoteDefault
MkCardDefault
MkChangelogDefault
MkClassDiagramRule of MkCodeFenced code block with plain language info string (no attributes).pymdownx.superfences
MkClassTableDefaulttables
MkCliDocDefault
MkCodeRuleFenced code block with plain language info string (no attributes).pymdownx.highlight, pymdownx.superfences
MkCodeOfConductDefault
MkCommandOutputDefault
MkCommentedCodeDefault
MkCommitConventionsDefault
MkCompactAdmonitionRule
MkConfigSettingDefault
MkContainerDefault
MkCriticRulepymdownx.critic
MkDataClassInfoDefault
MkDefinitionListRuledef_list
MkDependencyGroupsDefaulttables
MkDependencyTableDefaulttables
MkDetailsBlockRulepymdownx.blocks.details
MkDevEnvSetupDefault
MkDevToolsDefault
MkDiagramRule of MkCodeFenced code block with plain language info string (no attributes).pymdownx.superfences
MkDocStringsRuleAPI docs rendered from Griffe (GitHub has no mkdocstrings).
MkFootNotesDefaultfootnotes
MkHeaderDefault
MkHtmlBlockRuleThe element itself (/// html | picture -> <picture>...</picture>).pymdownx.blocks.html
MkHtmlTableRuleHTML table with unescaped Markdown cells (Material: <table markdown="1">).
MkIFrameDefault
MkIconRule
MkImageTemplate[output.github] in the node file
MkImageCompareDefault
MkImageSlideshowDefault
MkIncludeDefault
MkInstallGuideDefault
MkJupyterLiteDefault
MkKeysRulepymdownx.keys
MkLicenseDefault
MkLinkRule
MkListDefaultdef_list
MkLlmDefault
MkMaterialBadgeRule
MkMetadataBadgesDefault
MkModuleTableDefaulttables
MkPipDepTreeRule of MkCodeFenced code block with plain language info string (no attributes).pymdownx.superfences
MkProgressBarRulepymdownx.progressbar
MkPyDepsDefault
MkPyScriptDefault
MkPyodideTerminalDefault
MkReprRawRenderedDefault
MkShieldsDefault
MkShowcaseDefault
MkSpeechBubbleRule
MkTabRulepymdownx.tabbed
MkTabBlockRulepymdownx.blocks.tab
MkTabContainerRuleTabs become <details> blocks, the selected (or first) one expanded.
MkTabbedRule of MkTabContainerTabs become <details> blocks, the selected (or first) one expanded.pymdownx.tabbed, pymdownx.superfences
MkTabbedBlocksRule of MkTabContainerTabs become <details> blocks, the selected (or first) one expanded.pymdownx.blocks.tab
MkTableDefaulttables
MkTaskListDefaultpymdownx.tasklist
MkTemplateDefault
MkTextDefault
MkTimelineDefault
MkTreeViewRule of MkCodeFenced code block with plain language info string (no attributes).pymdownx.highlight, pymdownx.superfences
Page info
Code for this page

mknodes.manual.nodes_section._

@nav.route.page("Markdown flavours", icon="material/language-markdown")
def _(page: mk.MkPage) -> None:
    documented = [
        *BASE_NODES,
        *IMAGE_NODES,
        *PRESENTATION_NODES,
        *DOCUMENTATION_NODES,
        *ABOUT_THE_PROJECT_NODES,
        *CONTAINER_NODES,
        *SPECIAL_NODES,
    ]
    flavors.build_page(page, documented)

Resources
Resources(css=[],
          markdown_extensions={'md_in_html': {}, 'tables': {}},
          plugins=[],
          js=[],
          assets=[],
          packages=[])
Metadata
created:
  source_filename: /home/runner/work/mknodes/mknodes/src/mknodes/manual/nodes_section.py
  source_function: _
  source_line_no: 123
icon: material/language-markdown
title: Markdown flavours